<%@ page contentType="text/html; charset=utf-8" import="com.util.Component"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>成品卡验收登记</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<script src="${pageContext.request.contextPath }/scripts/boot.js"
	type="text/javascript"></script>
</head>
<style type="text/css">
html,body {
	margin: 0;
	padding: 0;
	border: 0;
	width: 100%;
	height: 100%;
	overflow: hidden;
}
</style>
<body>
	<form id="form1" method="post">
		<div>
			<table style="border:solid 1px #aaa;width:100%;">
				<tr>
					<td style="width:5%;white-space:nowrap;text-align: right;">制卡批次:</td>
					<td style="width:15%;text-align:left;"><input id="aaz001"
						name="aaz001" class="mini-textbox" maxLength="10"
						emptyText="请输入制卡批次"  required="true"/>
					</td>
					<td style="width:5%;white-space:nowrap;text-align: right;">银行：</td>
					<td style="width:15%;text-align:left;"><input id="aae008"
						name="aae008" class="mini-combobox" valueField="aaa102"
						textField="aaa103" emptyText="请选择银行" onvaluechanged="getvalue" required="true"
						url="${pageContext.request.contextPath }/kid.do?method=getyinhang&sj=bank" />
					</td>
					<td style="width:2%;white-space:nowrap;text-align: right;">制卡卡厂：</td>
					<td style="width:18%;text-align:left;"><input id="azf030"
						name="azf030" class="mini-combobox" valueField="azf030"
						textField="azf031" emptyText="请选择制卡卡厂" style="width:100%" required="true"
						url="${pageContext.request.contextPath }/Cpkys.do?method=getselectKC" enabled="false"/>
					</td>
					<td style="width:5%;white-space:nowrap;text-align: right;">到卡数量：</td>
					<td style="width:12%;text-align:left;"><input name="aaz709" required="true"
						class="mini-spinner" maxValue="100000"/><input name="aaz704" class="mini-hidden"/>
					</td>
					<td style="width:5%;white-space:nowrap;text-align: right;">到卡时间：</td>
					<td style="width:12%;text-align:left;"><input name="aaz710" required="true"
						class="mini-datepicker" allowInput="false" />
					</td>
					<td style="width: 6%;"><a class="mini-button"
						iconCls="icon-search" onclick="search()">查询</a>
					</td>
				</tr>
			</table>
		</div>
	</form>
	<div>
		<div class="mini-tabs" style="width:100%;height:420px;"
			activeIndex="0">
			<div title="无效卡人员">
				<div id="datagrid1" class="mini-datagrid"
					style="width:100%;height:100%;" allowResize="true"
					url="${pageContext.request.contextPath }/Cpkys.do?method=getWxk"
					idField="id" multiSelect="true">
					<div property="columns">
						<div type="checkcolumn"></div>
						<div field="aac001" width="120" headerAlign="center">社会保障卡号</div>
						<div field="aac003" width="120" headerAlign="center">姓名</div>
						<div field="aac004" width="120" headerAlign="center"  renderer="onGenderRenderer1">性别</div>
						<div field="aac002" width="120" headerAlign="center">身份证号码</div>
						<div field="aaz723" width="120" headerAlign="center"  renderer="onGenderRenderer">无效卡原因</div>
					</div>
				</div>
			</div>

			<div title="未制卡人员">
				<div style="width:100%;">
					<div class="mini-toolbar" style="border-bottom:0;padding:0px;">
						<table style="width:100%;">
							<tr>
								<td style="width:100%;"><a class="mini-button"
									iconCls="icon-add" onclick="addRow" tooltip="增加...">增加</a> <a
									class="mini-button" iconCls="icon-remove" onclick="removeRow">删除</a>
								</td>
							</tr>
						</table>
					</div>
				</div>
				<div id="datagrid2" class="mini-datagrid"
					style="width:100%;height:240px;"  idField="id"
                    multiSelect="true" allowResize="true">
					<div property="columns">
						<div type="checkcolumn"></div>

						<div field="aac0011" width="120" headerAlign="center">
							社会保障卡号 
						</div>
						<div field="aac0031" width="120" headerAlign="center">
							姓名
						</div>
						<div field="aac0041" width="80" headerAlign="center"  renderer="onGenderRenderer1">
							性别
						</div>
						<div field="aac0021" width="120" headerAlign="center">
							身份证号码
						</div>
	
						<div  autoShowPopup="true" field="aaz7231"
							width="120" headerAlign="center"  renderer="onGenderRenderer">
							不制卡原因
						</div>
					</div>
				</div>
<fieldset style="width:98%;border:solid 1px #aaa;margin-top:8px;position:relative;">
        <legend>详细信息</legend>
        <div id="editForm1" style="padding:5px;">
            <table  style="width:100%;">
                <tr>
                    <td  style="width:30%;white-space:nowrap;text-align:right"> 社会保障卡号 ：</td>
                    <td  style="width:10%;"><input id="aac0011" name="aac0011" class="mini-textbox" onenter="onKeyEnter1"/></td>
                    <td  style="width:10%;white-space:nowrap;text-align:right">不制卡原因：</td>
                    <td  style="width:50%;"><input id="aaz7231"  name="aaz7231"  class="mini-combobox" style="width:40%;"  valueField="aaa102" textField="aaa103" url="${pageContext.request.contextPath }/Cpkys.do?method=getselectWzk&AAA100=YZJG"/></td>
                </tr>
          </table>
        </div>
    </fieldset>
			</div>
			
						<div title="卡厂回卡质量问题人员">
				<div style="width:100%;">
					<div class="mini-toolbar" style="border-bottom:0;padding:0px;">
						<table style="width:100%;">
							<tr>
								<td style="width:100%;"><a class="mini-button"
									iconCls="icon-add" onclick="addRow1" tooltip="增加...">增加</a> <a
									class="mini-button" iconCls="icon-remove" onclick="removeRow1">删除</a>
								</td>
							</tr>
						</table>
					</div>
				</div>
				<div id="datagrid3" class="mini-datagrid"
					style="width:100%;height:240px;"  idField="id"
                    multiSelect="true" allowResize="true">
					<div property="columns">
						<div type="checkcolumn"></div>
						<div field="aac0012" width="120" headerAlign="center">
							社会保障卡号 
						</div>
						<div field="aac0032" width="120" headerAlign="center">
							姓名
						</div>
						<div field="aac0042" width="80" headerAlign="center"  renderer="onGenderRenderer1">
							性别
						</div>
						<div field="aac0022" width="120" headerAlign="center">
							身份证号码
						</div>
						<div  autoShowPopup="true" field="aaz7232"
							width="120" headerAlign="center"  renderer="onGenderRenderer">
							不制卡原因
						</div>
					</div>
				</div>
<fieldset style="width:98%;border:solid 1px #aaa;margin-top:8px;position:relative;">
        <legend>详细信息</legend>
        <div id="editForm2" style="padding:5px;">
            <table  style="width:100%;">
 <tr>
                    <td  style="width:30%;white-space:nowrap;text-align:right"> 社会保障卡号 ：</td>
                    <td  style="width:10%;"><input id="aac0012" name="aac0012" class="mini-textbox" onenter="onKeyEnter1"/></td>
                    <td  style="width:10%;white-space:nowrap;text-align:right">不制卡原因：</td>
                    <td  style="width:50%;"><input id="aaz7232"  name="aaz7232"  class="mini-combobox" style="width:40%;"  valueField="aaa102" textField="aaa103" url="${pageContext.request.contextPath }/Cpkys.do?method=getselectWzk&AAA100=YZJG"/></td>
                </tr>
          </table>
        </div>
    </fieldset>
			</div>
		</div>
		<div>
			<table style="table-layout:fixed;width:100%;" cellpadding="0"
				cellspacing="10">
				<tr style="width:100%;">
					<td style="width:44%;white-space:nowrap;"></td>
					<td style="width:6%;white-space:nowrap;"><a
						class="mini-button" onclick="onOk" enable="false"
						style="width:100%;" iconCls="icon-ok">确认</a>
					</td>
					<td style="width:6%;white-space:nowrap;"><a
						class="mini-button" onclick="onPrint" style="width:100%;"
						iconCls="icon-print">打印</a>
					</td>
					<td style="width:6%;white-space:nowrap;"><a
						class="mini-button" onclick="onReset" iconCls="icon-remove"
						style="width:100%;">重置</a>
					</td>
					<td style="width:44%;"></td>
				</tr>
			</table>
		</div>
		<script type="text/javascript">
	  	mini.parse();
        var form = new mini.Form("form1");
	  	var aaz001 = mini.getbyName("aaz001").getValue().trim();
	  	//无效卡人员
	    var grid = mini.get("datagrid1");
        grid.load();
        function search() {
		      var aaz001 = mini.getbyName("aaz001").getValue().trim();
		      var aae008 = mini.getbyName("aae008").getValue().trim();
		      var flag = aaz001.substring(0,2);
		      var len = aaz001.length;
		      if (aaz001 == "" || aae008 == "") {
		         mini.alert("请输入制卡批次与制卡银行！");
		         return;
		      }
		      if(flag != 'GR' && flag != 'DW' && len != 10){
		        		mini.alert("请输入以GR或者DW开头的十位制卡批次！")
		        		return ;
		      }
		      grid.load({ aaz001: aaz001, aae008: aae008});
	 	} 
	 //未制卡人员
	 	var grid1 = mini.get("datagrid2");
	 	var db = new mini.DataBinding();
        
        db.bindForm("editForm1", grid1);
	 	 /* var today = new Date();
	 	mini.getbyName("aae036").setValue(today);  */
	 	function addRow() {   
            var newRow = { name: "New Row" };
            grid1.addRow(newRow, "after");
            grid1.beginEditRow(newRow);
        }
        function removeRow() {
            var rows = grid1.getSelecteds();
            if (rows.length > 0) {
                grid1.removeRows(rows, true);
            }
        }
       //卡厂回卡质量问题人员
        var grid2 = mini.get("datagrid3");
        var db1 = new mini.DataBinding();
        db1.bindForm("editForm2", grid2);
	 	function addRow1() {   
            var newRow = { name: "New Row" };
            grid2.addRow(newRow, "after");
            grid2.beginEditRow(newRow);
        }
        function removeRow1() {
            var rows = grid2.getSelecteds();
            if (rows.length > 0) {
                grid2.removeRows(rows, true);
            }
        }
	 	//保存数据
	 	function saveData(){
        	var o =  grid.getData();
        	var o1 = grid1.getData();
        	var o2 = grid2.getData();
            var data = mini.encode(o);
            var data1 = mini.encode(o1);
            var data2 = mini.encode(o2);
            /* var aaz001 = mini.getbyName("aaz001").getValue().trim();
            var aaz709 = mini.getbyName("aaz709").getValue();
		    var aae008 = mini.getbyName("aae008").getValue().trim(); */
		    var o = form.getData();
			form.validate();
			if (form.isValid() == false) {
				return;
			}
			var json = mini.encode([ o ]);
            /*  alert(JSON.stringify(data)); */
             mini.mask({el: document.body,cls: 'mini-mask-loading',html: '保存中，请稍后......'});
            $.ajax({
                url: "${pageContext.request.contextPath}/Cpkys.do?method=saveWzk",
                data: { data:data,data1:data1,data2:data2,data3:json},
                type: "post",
                success: function (text) {
                mini.unmask();  
                	mini.alert(text);
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    mini.alert(jqXHR.responseText);
                }
            });
        }
        function onOk(e){
        	saveData();
        }
        function onReset(){
            form.reset();
            grid1.clearRows();
     		grid1.clearRows();
     		grid2.clearRows();
        }
        var Genders = [{ id: 0, text: '验卡正确' }, { id: 1, text: '卡类型不对'},{ id: 2, text: '个人编号不符' }, { id: 3, text: '姓名不符'},{ id: 4, text: '性别不符' }, { id: 5, text: '无效卡(信息不符)'},{ id: 6, text: '无照片' }, { id: 7, text: '无效卡(加急)'},{ id: 8, text: '照片不符' }, { id: 9, text: '卡厂原因'}, { id: 'A', text: '卡厂回卡质量问题' }, { id: 'B', text: '民族不符'}, { id: 'E', text: '实际未制卡'}];
        function onGenderRenderer(e) {
            for (var i = 0, l = Genders.length; i < l; i++) {
                var g = Genders[i];
                if (g.id == e.value) return g.text;
            }
            return "";
        }
        var Genders1 = [{ id: 1, text: '男' }, { id: 2, text: '女'}];
        function onGenderRenderer1(e) {
            for (var i = 0, l = Genders1.length; i < l; i++) {
                var g = Genders1[i];
                if (g.id == e.value) return g.text;
            }
            return "";
        }
        
        
         function onKeyEnter2()
        {
          var aac001 = mini.getbyName("aac0012").getValue().trim();  
          if(aac001=="")
          {
             mini.alert("请输入社会保障卡号");
             return;
          }
          else{                
           $.ajax({               
                    url: "/sbk/Cpkys.do?method=getunitdata",
                    cache: false,
                    data:{id:aac001},
                    success: function (text) {           
                             var o = mini.decode(text);                                             
                             var row =grid2.getSelected();
                             grid2.updateRow(row,{aac0032:o.aac003,aac0042:o.aac004,aac0022:o.aac002});
                        }
                });        
        }
        }
         function onKeyEnter1()
        {
          var aac001 = mini.getbyName("aac0011").getValue().trim(); 
          var aaz001 = mini.getbyName("aaz001").getValue().trim();  
          if(aac001=="")
          {
             mini.alert("请输入社会保障卡号");
             return;
          }else if(aaz001==""){
             mini.alert("请输入制卡批次");
             return;
          }
          else{                
           $.ajax({               
                    url: "/sbk/Cpkys.do?method=getunitdata",
                    cache: false,
                    data:{id:aac001,aaz001:aaz001},
                    success: function (text) {  
                             
                             var row =grid1.getSelected();   
                             if(text=='null'||text==""||text==null){
                             mini.alert("该批次不存在该人员或者该人员已经验证！");
                             grid1.removeRow(row, true);
                             return;
                             }else{  
                             var o = mini.decode(text); 
                             grid1.updateRow(row,{aac0031:o.aac003,aac0041:o.aac004,aac0021:o.aac002});
                             } 
                        }
                });        
        }
        }
        function getvalue(e){
        mini.getbyName("azf030").setValue("");
        var aaz001 = mini.getbyName("aaz001").getValue().trim(); 
        if(aaz001==""){
             mini.alert("请输入制卡批次");
             return;
        } 
         
         $.ajax({               
                    url: "/sbk/Cpkys.do?method=getvalue",
                    cache: false,
                    data:{aae008:e.value,aaz001:aaz001},
                    success: function (text) {  
                         var result= text.split(",");
                         if(result.length>2){
                         mini.getbyName("azf030").setValue(result[0]);
                         mini.getbyName("aaz704").setValue(result[1]);
                         }else{
                         mini.alert(result[0]);
                         }
                    }
                });        
        }
	</script>
</body>
</html>
